package com.java.generic;

import com.google.common.base.Suppliers;

/**
 * @program: study
 * @className: SelfBound
 * @description: TODO
 * @author: kukuxiahuni
 * @create: 2019-12-09 17:38
 * @version: v1.0
 **/
class SelfBound<T extends SelfBound<T>> {
    T element;

    SelfBound<T> set(T args) {
        this.element = args;
        return this;
    }

    T get() {
        return this.element;
    }
}

class A extends SelfBound<A> {
}

class B extends SelfBound<A> {
}

class C extends SelfBound<C> {

    C setAndGet(C args) {
        set(args);
        return get();
    }
}

class D {

}
//
//class E extends SelfBound<D> {
//}

class F extends SelfBound {

}

public class SelfBounding {

    public static void main(String[] args) {
        A a = new A();
        a.set(new A());

        a = a.set(new A()).get();
    }
}